<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../css/aui.css" />
		<style type="text/css">
			.aui-list .aui-list-item i.aui-iconfont {
				-webkit-align-self: center;
				align-self: center;
				font-size: 18px;
			}
			img.aui-img-round {
				border-radius: 1%;
			}
			.aui-tab-item.aui-active {
			    color: #039be5;
			    border-bottom: 2px solid #039be5;
			}
		</style>
	</head>
	<body>
		<div class="aui-tab" id="tab">
			<div class="aui-tab-item aui-active"  onclick="states(this)">
				我的部门
			</div>
			<div class="aui-tab-item"  onclick="state(this)">
				<!-- <div></div> -->
				所有部门
			</div>
		</div>
		<section class="aui-content">
			<ul class="aui-list aui-media-list" id="nice-articles" >
			</ul>
		</section>
		<section id="list"></section>
	</body>
	<script  type="text/javascript" src="../js/jquery.min.js"></script>
	<script type="text/javascript">
		$(function() {
			getPage(pageNumber, pageSize);
			$("#tab>div").click(function(){
				$(this).addClass('aui-active').siblings().removeClass('aui-active');
			})
		});
		
		function state(){
			getPages(pageNumber, pageSize);
		};
		function states(){
			getPage(pageNumber, pageSize);
		};
		
		
		function getPages(pageNumber, pageSize) {
				$.ajax({
					url : '${pageContext.request.contextPath}/getOtherCustomer.do',
					type : "POST",
					dataType : "json",
					success :function(data) {
					if (data.flag == 1 ) {
						if (data.data != "undefined") {
							var da = data.data;
							var html = "";
							for (var i = 0; i < da.length; i++) {
								html += '<li class="aui-list-item aui-list-item-middle"><div class="aui-media-list-item-inner"><div class="aui-list-item-media" style="width: 3rem;height: 3rem;"><img src="../img/bing.png" class="aui-img-round aui-list-img-sm"></div><div class="aui-list-item-inner"><div class="aui-list-item-text"><div class="aui-list-item-title aui-font-size-14">';
								if (da[i].deptName != null && da[i].deptName != "") {
									html += da[i].deptName;
								}
								html += '</div><div class="aui-list-item-right aui-font-size-14">';
								if (da[i].number != null && da[i].number != "") {
									html += "客户数量：" + da[i].number+"个";
								}
								html += '</div></div><div class="aui-list-item-text"><div class="aui-list-item-title aui-font-size-14"></div><div class="aui-list-item-right">'
								html += '</div></div></div></div></li>'
							}
						}
						//countSize = data.total;
						//复制总记录数
					} else {
						alert("暂无数据");
					}
					$("#nice-articles").html(html);
					}
				});
		
		}
		
						
		//当前初始页
		var pageNumber = 1;
		//每页显示多少条
		var pageSize = 10;
		var countSize = 0;
		function getPage(pageNumber, pageSize) {
			$.ajax({
				url : '${pageContext.request.contextPath}/queryEmployeeCustomerNumberByDeptId.do?page=' + pageNumber + '&limit=' + pageSize,
				type : "POST",
				dataType : "json",
				success : function(data) {
 					var html="";
					if (data.flag == "1") {
						if (typeof(data.data) != "undefined") {
 						var da = data.data;
						for (var i = 0; i < da.length; i++) {
							html += '<li class="aui-list-item aui-list-item-middle"><div class="aui-media-list-item-inner"><div class="aui-list-item-media" style="width: 3rem;height: 3rem;"><img src="../img/bing.png" class="aui-img-round aui-list-img-sm"></div><div class="aui-list-item-inner"><div class="aui-list-item-text"><div class="aui-list-item-title aui-font-size-14">';
							if (da[i].name != null && da[i].name != "") {
								html += da[i].name;
							}
							html += '</div><div class="aui-list-item-right aui-font-size-14">';
							if (da[i].customerNumber != null && da[i].customerNumber != "") {
								html += '客户数量：' + da[i].customerNumber + '个';
							} else {
								html += '客户数量：0个';
							}
							html += '</div></div><div class="aui-list-item-text"><div class="aui-list-item-title aui-font-size-14"></div><div class="aui-list-item-right">'
							html += '</div></div></div></div></li>'
						}
						//countSize = da.total;
						//复制总记录数
					} else {
						alert("暂无数据");
					}
					//alert(html);
					$("#nice-articles").html(html);
					}
				}
			});
		}
		
		
		function toDate(data) {
			var date = new Date(data);
			var y = date.getFullYear();
			var m = date.getMonth() + 1;
			m = m < 10 ? '0' + m : m;
			var d = date.getDate();
			d = d < 10 ? ('0' + d) : d;
			return y + '-' + m + '-' + d;
		}
	</script>
</html>